Fast Implementation Of Decoding Function For Variable Length Encoding

ABSTRACT

An embodiment of the present inventions is a method for encoding/decoding data of variable length format and is used to omit unnecessary pieces of data for the purpose of improving processing performance, reducing the size of data on communication paths and efficiently using limited physical memory. As examples of such variable length encoding, BER compression and UTF-8 encoding of UNICODE text, etc., are cited. While the amount of data can be reduced through encoding, before the data is actually used, it is necessary to restore (decode) it to the original data, which requires a great deal of processing time. One aspect of the present invention is improving decoding by reducing the processing time required to decode the encoded data.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of U.S. patent application Ser. No.11/621,285 filed Jan. 9, 2007, the contents of which are incorporated byreference herein in their entirety.

TRADEMARKS

IBM® is a registered trademark of International Business MachinesCorporation, Armonk, N.Y., U.S.A. Other names used herein may beregistered trademarks, trademarks or product names of InternationalBusiness Machines Corporation or other companies.

BACKGROUND OF THE INVENTION

1. Field of the Invention

This invention relates to a method for encoding/decoding data of avariable length format and in particular to using the method to omitunnecessary pieces of data for the purpose of improved processingperformance, reducing the size of data on communication paths, andefficiently using limited physical memory.

2. Description of Background

Before our invention encoding data is commonly utilized as a way inwhich to compress and reduce the physical size of the data whilemaintaining the data integrity. As such, a variety of encoding anddecoding algorithms are available and many have been optimized forparticular types and or kinds of data.

A problem with current encoding schemes is that data is encoded with noconsideration given to efficiently encoding the data such that decodeprocessing time is minimized. In this regard, existing decoding/encodingprograms are inefficient and require lots of processing time to decodethe data.

As such, current encoding and decoding routines are inefficient, andtypically process unnecessary data. All of which consumes valuableprocessing time, and increases the size of data on communication paths.As such, eliminating unnecessary data by way of an improved encoding anddecoding method resulting in a method of speeding up decoding processingtime significantly improves processing performance and in part givesrise to the present invention.

SUMMARY OF THE INVENTION

The shortcomings of the prior art are overcome and additional advantagesare provided through the provision of a method of simultaneousprocessing data elements in decoding operation of variable lengthencoded data, said method comprising: collecting a plurality of data tobe decoded; determining an encoded data length for each of the pluralityof data; obtaining a plurality of parameters based on the determinationof the encoded data length of each of the plurality of data; andperforming operations on each of the plurality of data.

System and computer program products corresponding to theabove-summarized methods are also described and claimed herein.

Additional features and advantages are realized through the techniquesof the present invention. Other embodiments and aspects of the inventionare described in detail herein and are considered a part of the claimedinvention. For a better understanding of the invention with advantagesand features, refer to the description and to the drawings.

TECHNICAL EFFECTS

As a result of the summarized invention, technically we have achieved asolution, which is a method of speeding up the decoding of encoded data.

BRIEF DESCRIPTION OF THE DRAWINGS

The subject matter, which is regarded as the invention, is particularlypointed out and distinctly claimed in the claims at the conclusion ofthe specification. The foregoing and other objects, features, andadvantages of the invention are apparent from the following detaileddescription taken in conjunction with the accompanying drawings inwhich:

FIG. 1 illustrates one example of a program restoration processing;

FIG. 2 illustrates one example of permute instruction of VMX;

FIG. 3 illustrates one example of a method of simultaneous processing ofa plurality of elements in decoding operations of variable lengthencoding data routine 1000;

FIG. 4 illustrates one example of a program for restoration processingby way of routine 1000;

FIG. 5 illustrates one example of a decoding operation;

FIG. 6 illustrates one example of obtaining parameters and performingoperations of routine 1000 specific to BER compression decoding;

FIG. 7 illustrates one example of obtaining parameters and performingoperations of routine 1000 specific to UTF-8 decoding;

FIG. 8 illustrates one example of the performance of decoding of simpleencoding of Table 1;

FIG. 9 illustrates one example of the performance of decoding of BERcompression; and

FIG. 10 illustrates one example of the performance of UTF-8 decoding.

The detailed description explains the preferred embodiments of theinvention, together with advantages and features, by way of example withreference to the drawings.

DETAILED DESCRIPTION OF THE INVENTION

Turning now to the drawings in greater detail, in an exemplaryembodiment of the present invention a method of variable lengthencoding/decoding of a plurality of data simultaneously is utilized toreduce the number of conditional branching instructions and arithmeticinstructions, which cause a lowering of execution efficiency, and assuch a realization of higher speed processing, mainly through a permuteinstruction.

To explain the decoding of variable length encoding, an example ofsimplified encoding rule is shown in Table 1 below. In the encoding,integer type data of up to 30 bits in length is expressed by a dataformat of 1 to 4 bytes, with a 2-bit prefix being added.

TABLE 1 Encoded Input data data 2-bit Format [first byte] [second byte]. . . length length prefix X: data bit 1 to 6 bits 1 byte 0 (00b)[00xxxxxx] 7 to 14 bits 2 bytes 1 (01b) [01xxxxxx] [xxxxxxxx] 15 to 22bits 3 bytes 2 (10b) [10xxxxxx] [xxxxxxxx] [xxxxxxxx] 23 to 30 bits 4bytes 3 (11b) [11xxxxxx] [xxxxxxxx] [xxxxxxxx] [xxxxxxxx]

In the encoding, if the ratio of data having a short input data lengthis higher, the amount of data will be reduced. One example of a programfor performing restoration of the encoded data according to this rule isillustrated in FIG. 1.

As illustrated in FIG. 1, since the restoration operation of thevariable length data generally includes a number of conditional branchesand the decoding of each element concurrently depends on the decoding ofthe previous element, there is the problem that the parallelism of theinstruction level is lowered.

As a premise of the present invention, an explanation will be givenregarding the permute instruction (as example see IBM Corp. PowerPCMicroprocessor Family: Vector/SIMD Multimedia Extension TechnologyProgramming Environments Manual). A permute (or shuffle) instruction isan instruction for rearranging the content of the input register in anarbitrary order. To give an example of the permute instruction of theVMX, which is an SIMD instruction set of the PowerPC, three 16-bytevector registers are treated as input, one vector register as output,and the data of the vector register as sixteen 1-byte rows,respectively. In this instruction, the first and second arguments arefirst of all combined in this order to make thirty-two 1-byte rows.Based on this, the byte value at the position indicated by the locationof the value of the lower 5 bits of each element of the third argumentis returned as a return value of the position corresponding to theelement. Thus, it becomes possible to rearrange the input data in unitsof bytes in an arbitrary order. An example of the operation of thepermute instruction of the VMX one example of which is illustrate inFIG. 2.

Explanations will be given regarding the method of the presentinvention, using the format shown above in the table as an example. Thatis to say, an arrangement expressed by variable length encoding of 1 to4 bytes is decoded in order to be output as an arrangement of a 32-bitinteger. According to the method of the present invention, a pluralityof data is processed simultaneously. However, explanations will be givenon the basis of 4 pieces of data being processed simultaneously. Thiscorresponds to a case where, by using a register of 16-byte length, a32-bit integer is processed. However, the present method is not limitedto this parallelism; 8 pieces of data (8 characters) will be decodedsimultaneously in the decoding of the UTF-8 to be described later.Furthermore, the present invention is mainly intended for the decodingof encoded data, however, the object is not limited to this use. Forexample, it is possible apply it in encoding, using the rulesillustrated in the table above.

Referring to FIG. 3 there is illustrated one example of a method ofsimultaneous processing of a plurality of elements in decodingoperations of variable length encoding data routine 1000. In anexemplary embodiment, the present method collects the data length of theplurality of data to be processed, obtains the necessary parameters bylooking up a table or performing operations, and performs operationsusing the obtained parameters, simultaneously processing the pluralityof data. The method begins in block 1002.

In block 1002 the data length of the plurality of data to be processedis collected. Processing then moves to block 1004.

In block 1004 the parameters by looking up a table or performingoperations is obtained. In this regard, FIGS. 6 and 7 further illustratethe process of obtaining in block 1004 and performing in block 1006.Processing then moves to block 1006.

In block 1006 operations using the obtained parameters are performedsimultaneously processing the plurality of data. The routine in thenexited.

Referring to FIG. 4 there is illustrated one example of such processing.In the example in FIG. 4, the prefixes of 4 pieces of input data arecollected (functionality of block 1004). Two parameters are loaded,which are vpattern for rearranging data through the permute instructionand vmask for masking prefix bits (functionality of block 1004). Afterthe encoded data is loaded, processing is actually performed by usingtwo parameters (functionality of block 1006).

Here, if the prefix of the 4 pieces of input data is, for example, in anorder of [0, 1, 2, 1], a constant number table is prepared, in order forthe values of the two parameters to become as follows.

vpattern={*, *, *, 0x00, *, *, 0x01, 0x02, *, 0x03, 0x04, 0x05, *, *,0x06, 0x07}

vmask={0, 0, 0, 0x3F, 0, 0, 0x3F, 0xFF, 0, 0x3F, 0xFF, 0xFF, 0, 0, 0x3F,0xFF}

Additionally, ‘*’ denotes an arbitrary value. One example of processingin this case is illustrated in FIG. 5. Advantages of this program are,as compared with the code of FIG. 1 that four pieces of data can beprocessed at one time and, since conditional branching is not used,there are no penalties from branching mis-predictions. Furthermore, theprocessing of block 1002 does not depend on that of block 1004 and block1006 in the previous iteration; therefore, it can be executed inparallel, having the parallelism of a high instruction level, ascompared to the code in FIG. 1. In addition, in FIG. 4, for the purposeof explanation, block 1002 functionality is described through scalarinstructions; however, this part can be processed through SIMDinstructions as well.

Conversely, the problem is that a table lookup in block 1004functionality or operation costs become necessary. In an exemplaryembodiment, referred to as embodiment 1 in FIG. 6, using the program inFIG. 4 can perform decoding of the simple encoding of the Table 1 shownabove.

In another exemplary embodiment, referred to as embodiment 2 in FIG. 6,decoding of BER (Basic Encoding Rules) compression can be effectuated.In this regard, a variable length encoding format that is included inITU-T recommendation X.690 (ITU-T Recommendation X.690, Informationtechnology—ASN.1 encoding rules: Specification of Basic Encoding Rules(BER), Canonical Encoding Rules (CER) and Distinguished Encoding Rules(DER)), and it is widely employed not only in the communication fieldbut also in various fields of application. BER compression is variablelength encoding, which shows that in 1 byte of data, the first bit is aflag and the remaining 7 bits are data, and when the flag bit is 1, thebyte continues to the following byte. While this encoding rule is morecomplicated it is possible to perform processing in nearly the samefashion as decoding in embodiment 1.

Referring to FIG. 6 there is illustrated logic for making some decisionsand applying rules. An example is illustrated in FIG. 6, which can beimplemented by the VMX. In FIG. 6, the Select is the select instructionof the VMX, using the value of the register as a mask, which is thethird argument, and it is the instruction to output the correspondingbit of the first argument when the mask bit is ‘0’ and to output thecorresponding bit of the second argument when the mask bit is ‘1’.

Referring to FIG. 7 there is illustrated one example of example of Steps2 and 3 of UTF-8 decoding. In an exemplary embodiment, referred to asembodiment 3 in FIG. 7, a more complicated example is shown that decodestext of the UTF-8 encoded UNICODE (UCS-2). In the decoding of UTF-8,data transfer has to be conducted by bit as well. In UTF-8, whenexpressing the character code of UCS-2, it is encoded into any one ofthree kinds of encoding; one byte (ASCII character, 0x00-0x7F), twobytes (Latin character, etc., 0x80-0x7FF), or three bytes (Japanese,etc., 0x800-0xFFFF). As an example, when it is encoded into three-bytelength data, three-byte UTF-8 data of [1110xxxx], [10yyyyyy], and[10zzzzzz] has to be transformed into two-byte UNICODE characters of[xxxxyyyy] and [yyzzzzzz], which cannot be realized through sorting onlyin units of bytes.

Even in such a case, although the number of parameters and operations tobe performed may increase, routine 1000 of the present invention isapplicable. Various alternative methods are conceivable for performingoperations; however, as an example, the VMX can perform operations asshown in FIG. 7. An instruction set having more flexible instructions,such as the permute instruction in units of bits can perform moreefficient operations.

Routine 1000 of the present invention has been implemented andevaluated. The results of performance evaluations of Embodiments 1 and2, conducted on the PowerPC970 and the SPE of the Cell BE processor, areillustrated in FIGS. 8 and 9. In either example, great improvements inperformance are obtained by using the present invention in each design.

The performance of decoding the UTF-8 of embodiment 2, implemented onthe PowerPC970, is shown in FIG. 10. The label of the x-axis is the typeof document, input size (KB)->output size (KB). The three on the left,among the input data used in the test, are artificial data, and they areinput in the form of all 1-byte characters (ASCII text), all 3 bytecharacters (Japanese text), and repetitions of 1, 2, and 3 bytes. Othersare text files in real world (mainly HTML), in which the characters tobe encoded into all 1-byte characters and into 2 or 3 bytes areintermingled. The graph shown is the relative performance of theimplementation compared to a tuned implementation without the method ofthe present invention. When using the method of the present invention,higher performance is obtained for all documents.

The capabilities of the present invention can be implemented insoftware, firmware, hardware or some combination thereof.

As one example, one or more aspects of the present invention can beincluded in an article of manufacture (e.g., one or more computerprogram products) having, for instance, computer usable media. The mediahas embodied therein, for instance, computer readable program code meansfor providing and facilitating the capabilities of the presentinvention. The article of manufacture can be included as a part of acomputer system or sold separately.

Additionally, at least one program storage device readable by a machine,tangibly embodying at least one program of instructions executable bythe machine to perform the capabilities of the present invention can beprovided.

The flow diagrams depicted herein are just examples. There may be manyvariations to these diagrams or the steps (or operations) describedtherein without departing from the spirit of the invention. Forinstance, the steps may be performed in a differing order, or steps maybe added, deleted or modified. All of these variations are considered apart of the claimed invention.

While the preferred embodiment to the invention has been described, itwill be understood that those skilled in the art, both now and in thefuture, may make various improvements and enhancements which fall withinthe scope of the claims which follow. These claims should be construedto maintain the proper protection for the invention first described.

1. A method of simultaneous processing data elements in decoding operation of variable length encoded data, said method comprising: collecting a plurality of data to be decoded; determining an encoded data length for each of said plurality of data; obtaining a plurality of parameters based on the determination of said encoded data length of each of said plurality of data, wherein obtaining includes accessing a table to lookup said plurality of parameters and performing operations to obtain said plurality of parameters; permuting said plurality of data; rearranging each of said plurality of bytes by permutation; and decoding said plurality of data by a plurality of rules; wherein said plurality of rules includes simple format rules.
 2. A method of simultaneous processing data elements in decoding operation of variable length encoded data, said method comprising: collecting a plurality of data to be decoded; determining an encoded data length for each of said plurality of data; obtaining a plurality of parameters based on the determination of said encoded data length of each of said plurality of data, wherein obtaining includes accessing a table to lookup said plurality of parameters and performing operations to obtain said plurality of parameters; permuting said plurality of data; rearranging each of said plurality of bytes by permutation; and decoding said plurality of data by a plurality of rules; wherein said plurality of rules includes basic encoding rules.
 3. A method of simultaneous processing data elements in decoding operation of variable length encoded data, said method comprising: collecting a plurality of data to be decoded; determining an encoded data length for each of said plurality of data; obtaining a plurality of parameters based on the determination of said encoded data length of each of said plurality of data, wherein obtaining includes accessing a table to lookup said plurality of parameters and performing operations to obtain said plurality of parameters; permuting said plurality of data; rearranging each of said plurality of bytes by permutation; and decoding said plurality of data by a plurality of rules; wherein said plurality of rules includes decoding of UTF-8. 